﻿<?php
$id=$_GET[id];
$ids = array(
"hxws"=>"5901b5c5f53870240936be69",//海峽衛視(原免费)
"yzly"=>"543f5a443d32fc7b0e3322d1",//亞洲旅遊台(原免费)
"bswq"=>"543f45023d32fc7b0e33229e",//博斯網球台HD
"bsml"=>"543f45693d32fc7b0e3322a2",//博斯魅力網HD
"bsgq1"=>"543f44443d32fc7b0e332298",//博斯高球一台HD
"bsgq2"=>"543f446e3d32fc7b0e33229a",//博斯高球二台HD
"bsyd1"=>"543f44b73d32fc7b0e33229c",//博斯運動一台HD
"bsyd2"=>"543f45923d32fc7b0e3322a4",//博斯運動二台HD
"bswx"=>"543f45333d32fc7b0e3322a0",//博斯無限台HD
"bswx2"=>"54cb498d41a170b950afe1f3",//博斯無限二台HD
"msxq"=>"543f599a3d32fc7b0e3322cd",//美食星球
"smart"=>"543f5c5b3d32fc7b0e3322e1",//Smart知識頻道
"mdqys"=>"5440b1653d32fc7b0e332586",//梅迪奇藝術頻道HD
"jtyl"=>"5b39a7526e6b3b956ef95010",//靖天育樂台
"jtzx"=>"5b39a75b6e6b3b956ef95011",//靖天資訊台
"ylgj"=>"543f5a6f3d32fc7b0e3322d3",//亞旅國際HD
"lhkt"=>"543f5baf3d32fc7b0e3322d9",//龍華卡通台
"jykt"=>"5b39aaac6e6b3b956ef95045",//靖洋卡通台
"jtkt"=>"5b39a7726e6b3b956ef95012",//靖天卡通台
"xfly"=>"543f5aad3d32fc7b0e3322d5",//幸福旅遊
"hyxw"=>"543f39dcbe8f33ec180fc541",//寰宇新聞頻道HD
"hyxwtw"=>"543f3e033d32fc7b0e332285",//寰宇新聞台灣台
"hycj"=>"543f3e273d32fc7b0e332287",//寰宇財經台
"msxw"=>"56a747f6981e0c7f0a06129a",//民視新聞台
"dsyzxw"=>"543f3e663d32fc7b0e332289",//東森亞洲新聞台
"fhwszw"=>"5a052644f9d70b2167700f95",//鳳凰衛視中文台
"fhwszx"=>"543f439f3d32fc7b0e332294",//鳳凰衛視資訊台
"cctv"=>"5746aad682928c144dc57f74",//CCTV中文國際頻道
"gh1"=>"59507ba147aa327b5f93c94a",//國會頻道一台
"gh2"=>"59c485263ae968f0351e380c",//國會頻道二台
"asia"=>"5b5e9183af9fd7e4450aef9c",//Channel News Asia
"tv5"=>"59fc45ed9e5098fa27519683",//法國TV5電視台
"24"=>"546d5324ae89717668a16258",//法國24電視台
"euronews"=>"5478163f2f98a92b9febd51c",//EuroNews
"rjws"=>"543f5c043d32fc7b0e3322dd",//人間衛視
"wss"=>"5c6a302e63e711217777ac3a",//無上師電視台YTB
"hxxzh"=>"5a461eb9bfdf3f8906674f3a",//好消息綜合台
"hxxzl"=>"5a461f69bfdf3f8906674f3b",//好消息真理台
"dsgw1"=>"549e67b276d76482a52641fd",//東森購物1台
"dsgw5"=>"57c3eba20e5db6d06975e327",//東森購物5台YTB
"wx"=>"574bb9c9ec078dd716166de5",//唯心電視台
"mstw"=>"56a7482c981e0c7f0a06129c",//民視台灣台
"sm"=>"5de895b09099fdb5504fea30",//生命電視台
"ms"=>"56a74816981e0c7f0a06129b",//民視
"ettoday"=>"5b5559edafd486d41653b196",//ETtoday綜合台
"hyzh"=>"543f49113d32fc7b0e3322bf",//寰宇綜合HD
"yzzh"=>"543f495f3d32fc7b0e3322c1",//亞洲綜合台
"dsyz"=>"543f4abd3d32fc7b0e3322c7",//東森亞洲台
"lhxj"=>"543f46cc3d32fc7b0e3322b0",//龍華戲劇HD
"lhox"=>"543f47123d32fc7b0e3322b2",//龍華偶像台
"lhrh"=>"543f47933d32fc7b0e3322b7",//龍華日韓台
"lhdy"=>"599d3c1f8592c31a4b8d177e",//龍華電影台
"jtxj"=>"5b39a7436e6b3b956ef9500f",//靖天戲劇台
"jthl"=>"5b39a6fa6e6b3b956ef9500c",//靖天歡樂台
"jtrb"=>"5b39a70a6e6b3b956ef9500d",//靖天日本台
"jtzh"=>"5b39a6e76e6b3b956ef9500b",//靖天綜合台
"da1"=>"5a0571e0f9d70b216770235e",//大愛一臺YTB
"kj"=>"5551a7cddedfaf7c14d34107",//客家電視
"mszy"=>"57c521f8025574e040adcec7",//民視綜藝台
"lhyp"=>"5b3c6717416275ac3734ce68",//龍華洋片台
"lhjd"=>"549e6eff76d76482a526439d",//龍華經典台
"jtyh"=>"5b39a71f6e6b3b956ef9500e",//靖天映晝
"ktl"=>"5b39a79e6e6b3b956ef95013",//KTL-靖天國際台
"da2"=>"5a057245f9d70b216770235f",//大愛二臺YTB
"dahw"=>"5a057281f9d70b2167702360",//大愛海外臺YTB
"gg"=>"5580f6a7dedfaf7c14d343c7",//公共電視YTB
);
$user = mt_rand().time();
$user = substr(md5($user),5,16);
$device = substr(md5($user),6,16);
$signup = "username=".$user."@gmail.com&password=11223344&deviceId=".$device."&mobilePhone=&authType=url";
$data = "username=".$user."@gmail.com&password=11223344&deviceId=".$device;
$url = "http://ftvn.hawsing.com.tw:3000/client/usersignup";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $signup);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0' );
#curl_setopt($ch, CURLOPT_PROXY, 'xxx.xxx.xxx:xxxxx');填入代理ip加端口,可选
$up = curl_exec($ch);
$url = "http://ftvn.hawsing.com.tw:3000/client/login";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0' );
#curl_setopt($ch, CURLOPT_PROXY, 'xxx.xxx.xxx:xxxxx');填入代理ip加端口,可选
$re = curl_exec($ch);
$token = json_decode($re)->token;
$Authorization = "token ".$token;
$header = array(
"User-Agent: Mozilla/5.0",
"Authorization: $Authorization",
);
$url = "http://ftvn.hawsing.com.tw:3000/client/api/getLiveChannelURL";
$post = "channelid=".$ids[$id]."&ver=2";//为变量，区分节目
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
#curl_setopt($ch, CURLOPT_PROXY, 'xxx.xxx.xxx:xxxxx');填入代理ip加端口,可选
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result)->data->url;
header('Location:'.$result);
?>